import 'package:flutter/material.dart';
import 'package:flutter_app/config/colorconfig.dart';
import 'package:flutter_app/tabs/userpage/collect.dart';
import 'package:flutter_app/tabs/userpage/journal.dart';
import 'package:flutter_app/tabs/userpage/list.dart';

class MyUserPage extends StatefulWidget {
  MyUserPage({Key key}) : super(key: key);

  @override
  _MyUserPageState createState() => _MyUserPageState();
}

class _MyUserPageState extends State<MyUserPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        automaticallyImplyLeading: false,
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Column(
          children: <Widget>[
            Text("昵称XXX",
                style: TextStyle(
                  color: Colors.green,
                )),
            Text(
              "ID:xxxxxx",
              textScaleFactor: 0.7,
              style: TextStyle(
                color: Colors.grey[500],
              ),
            ),
          ],
        ),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.settings),
            onPressed: () {
              Navigator.of(context).pushNamed('/setting');
            },
            color: Colors.blueGrey,
          ),
        ],
      ),
      body: Column(
        children: <Widget>[
          SizedBox(
            height: 10,
          ),
          Expanded(
              flex: 3,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                      flex: 1,
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                        children: <Widget>[
                          Center(
                            child: ClipOval(
                              child: Container(
                                height: 80,
                                width: 80,
                                color: defaultgreen,
                              ),
                            ),
                          ),
                          Text(
                            "性别/国家/所在地",
                            textScaleFactor: 0.7,
                          ),
                        ],
                      )),
                  Expanded(
                    flex: 3,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: <Widget>[
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          children: <Widget>[
                            RaisedButton(
                              onPressed: () {
                                Navigator.of(context).pushNamed('/fans');
                              },
                              child: Column(
                                children: <Widget>[
                                  Text(
                                    "0",
                                    textScaleFactor: 0.7,
                                  ),
                                  Text(
                                    "粉丝",
                                    textScaleFactor: 0.9,
                                  ),
                                ],
                              ),
                            ),
                            RaisedButton(
                              onPressed: () {
                                Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                        builder: (context) => collectPage()));
                              },
                              child: Column(
                                children: <Widget>[
                                  Text(
                                    "0",
                                    textScaleFactor: 0.7,
                                  ),
                                  Text(
                                    "收藏",
                                    textScaleFactor: 0.9,
                                  ),
                                ],
                              ),
                            ),
                            RaisedButton(
                              onPressed: () {
                                Navigator.of(context).pushNamed('/follow');
                              },
                              child: Column(
                                children: <Widget>[
                                  Text(
                                    "0",
                                    textScaleFactor: 0.7,
                                  ),
                                  Text(
                                    "关注",
                                    textScaleFactor: 0.9,
                                  ),
                                ],
                              ),
                            )
                          ],
                        ),
                        Text(
                          "添加个人描述，让更多的人认识你",
                          textScaleFactor: 0.9,
                        ),
                        Container(
                          height: 25,
                          child: RaisedButton(
                            onPressed: () {},
                            color: Colors.white,
                            child: Text("编辑个人资料"),
                            padding: EdgeInsets.fromLTRB(100, 0, 100, 0),
                            shape: StadiumBorder(
                                side: BorderSide(
                              style: BorderStyle.solid,
                              color: defaultgreen,
                            )),
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              )),
          Expanded(
              flex: 10,
              child: DefaultTabController(
                length: 2,
                child: Scaffold(
                    appBar: PreferredSize(
                        preferredSize: Size(50, 50),
                        child: AppBar(
                          automaticallyImplyLeading: false,
                          elevation: 0,
                          backgroundColor: Colors.white,
                          centerTitle: true,
                          title: Container(
                            height: 40,
                            width: 200,
                            child: TabBar(
                              indicatorColor: Colors.lightGreenAccent,
                              tabs: <Widget>[
                                Tab(
                                  child: Text("手账",
                                      textScaleFactor: 0.9,
                                      style:
                                          TextStyle(color: Colors.lightGreen)),
                                ),
                                Tab(
                                  child: Text("打卡",
                                      textScaleFactor: 0.9,
                                      style:
                                          TextStyle(color: Colors.lightGreen)),
                                ),
                              ],
                            ),
                          ),
                        )),
                    body: TabBarView(
                      children: <Widget>[
                        MyJournal(),
                        MyList(),
                      ],
                    )),
              )),
        ],
      ),
    );
  }
}
